unit O_ImageButton;

interface

uses
  Classes,ExtCtrls, Windows, Messages, Graphics;

type
  TCrackComponent=class(Tcomponent)end;

  TImageButton = class(TImage)
  private
    FRectList: array[1..8] of TRect;
  protected
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    procedure Resize;override;
    procedure WmSize(var Msg: TWmSize);message wm_Size;
  public
    constructor Create(AOwner: TComponent); override;
  end;

implementation

{ TImageButton }

constructor TImageButton.Create(AOwner: TComponent);
begin
  inherited;

end;



procedure TImageButton.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
  inherited;

end;


procedure TImageButton.Resize;
var
  R: TRect;
begin
  inherited;

{  R := BoundsRect;
  InflateRect(R, -2, -2);
  BoundsRect := R;
  FRectList[1] := Rect(0, 0, 5, 5);
  FRectList[2] := Rect(Width div 2 - 3, 0, Width div 2 + 2, 5);
  FRectList[3] := Rect(Width - 5, 0, Width, 5);
  FRectList[4] := Rect(Width - 5, Height div 2 - 3, Width, Height div 2 + 2);
  FRectList[5] := Rect(Width - 5, Height - 5, Width, Height);
  FRectList[6] := Rect(Width div 2 - 3, Height - 5, Width div 2 + 2, Height);
  FRectList[7] := Rect(0, Height - 5, 5, Height);
  FRectList[8] := Rect(0, Height div 2 - 3, 5, Height div 2 + 2);
  }
end;

procedure TImageButton.WmSize(var Msg: TWmSize);
var
  R: TRect;
begin
  R := BoundsRect;
  InflateRect(R, -2, -2);
  BoundsRect := R;
  FRectList[1] := Rect(0, 0, 5, 5);
  FRectList[2] := Rect(Width div 2 - 3, 0, Width div 2 + 2, 5);
  FRectList[3] := Rect(Width - 5, 0, Width, 5);
  FRectList[4] := Rect(Width - 5, Height div 2 - 3, Width, Height div 2 + 2);
  FRectList[5] := Rect(Width - 5, Height - 5, Width, Height);
  FRectList[6] := Rect(Width div 2 - 3, Height - 5, Width div 2 + 2, Height);
  FRectList[7] := Rect(0, Height - 5, 5, Height);
  FRectList[8] := Rect(0, Height div 2 - 3, 5, Height div 2 + 2);
end;





end.
